Skip to content

Allow use of multiple extension galleries #2620

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

Conversation

oxy
Copy link

@oxy oxy commented Jan 22, 2021

This PR should implement support for using multiple extension galleries by default.
There's quite a few things that may be slightly hacky about it, since VSCode's extension gallery design is confusingly broken:

  • galleryUrl is used for /extensionquery and uninstall statistics
  • itemUrl is supposedly used for linking to item pages but is not essential for functionality (and our gallery doesn't support it) so I just left it out
  • controlUrl appears to be used for reporting malicious extensions, neither OpenVSX nor our gallery supports this
  • recommendationsUrl provides recommendations but neither OpenVSX nor our gallery supports this

Awkward thing here is that galleryUrl on first glance appears to be the base URL for the whole API, and internally /extensionquery is appended to it, but then they go ahead and include separate URLs for other extension gallery functionality - which is quite confusing.

So, I just changed the type of galleryUrl from string to string[] and patched the methods that read from it.

It might also be possible to change the type of extensionGallery to a list of objects instead of an object with a list of galleryUrl - but given that the other variables aren't really used by either of the two galleries we plan to primarily support (ours and OpenVSX's), so I tried to minimize engineering time there.

I've tested the result by installing extensions from both OpenVSX and our repo - and it works fine!

Also, right now, I don't actually resort results to merge the two lists; it's just all of OpenVSX's first page, with all of Coder's (with duplicates filtered) after that.

@oxy oxy requested a review from jsjoeio January 22, 2021 17:01
@oxy oxy force-pushed the multiple-galleries branch from d025f0e to e7a8d89 Compare January 22, 2021 17:05
@jsjoeio
Copy link
Contributor

jsjoeio commented Jan 22, 2021

@jsjoeio
Copy link
Contributor

jsjoeio commented Jan 22, 2021

Also, right now, I don't actually resort results to merge the two lists; it's just all of OpenVSX's first page, with all of Coder's (with duplicates filtered) after that.

Just to clarify here - are only the first page of OpenVSX's extensions available with this change? Or are all of them available?

Copy link
Contributor

@jsjoeio jsjoeio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work @oxy 🎉 I'm so excited for this. I left a few minor non-blocking suggestions and questions. Might be good to get an eye from someone else on the team just as extra assurance.

private api(path = ''): string {
return `${this.extensionsGalleryUrl}${path}`;
private api(path = ''): string[] {
if (!!this.extensionsGalleryUrl) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the double ! to convert it to a boolean? Does it have a performance advantage over the Boolean function? Only asking/suggesting if it might improve readability - obviously your call :D

Suggested change
if (!!this.extensionsGalleryUrl) {
if (Boolean(this.extensionsGalleryUrl)) {

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps I should just use this.isEnabled() instead - does the same check in practice but is probably ideal since the code already exists.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good thinking!

}

async reportStatistic(publisher: string, name: string, version: string, type: StatisticType): Promise<void> {
// TODO: investigate further - currently we just send stats everywhere
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know folks have GitLens and tools to know who left a TODO comment but at least this puts your name right there so we don't forget.

Suggested change
// TODO: investigate further - currently we just send stats everywhere
// TODO(oxy): investigate further - currently we just send stats everywhere

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 will fix!

}

async reportStatistic(publisher: string, name: string, version: string, type: StatisticType): Promise<void> {
// TODO: investigate further - currently we just send stats everywhere
// this is only used in one place - uninstall tracking - but
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfinished comment? Was there more to this sentence?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, there was!
was supposed to say but unsure if MS will start using this elsewhere

@oxy
Copy link
Author

oxy commented Feb 5, 2021

We've decided on an alternate approach for now; see #2659 and #2672.

@oxy oxy closed this Feb 5, 2021
@jsjoeio jsjoeio deleted the multiple-galleries branch February 8, 2021 16:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants